while migrating from another version, clean updater config
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Fri, 17 Jan 2025 14:02:29 +0000 (15:02 +0100)
committerMatthieu Gallien <matthieu.gallien@nextcloud.com>
Tue, 11 Feb 2025 09:57:01 +0000 (10:57 +0100)
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/gui/application.cpp
src/libsync/configfile.cpp
src/libsync/configfile.h

index 4175ae5f0649b4b83cb1de58eed690dca21b959d..10bf7cfaa736c07dcde64ddc5aa0883cd13d3d98 100644 (file)
@@ -143,6 +143,10 @@ bool Application::configVersionMigration()
     const auto versionChanged = previousVersion != currentVersion;
     const auto downgrading = previousVersion > currentVersion;
 
+    if (versionChanged) {
+        configFile.cleanUpdaterConfiguration();
+    }
+
     if (!versionChanged && !(!deleteKeys.isEmpty() || (!ignoreKeys.isEmpty() && versionChanged))) {
         return true;
     }
index 37ea14d6ff3d370272ce21b46cc4af4f79a785d7..93e9f2cbfa039a84dc30ca11a861588cb01125f1 100644 (file)
@@ -453,6 +453,17 @@ QString ConfigFile::excludeFileFromSystem()
     return fi.absoluteFilePath();
 }
 
+void OCC::ConfigFile::cleanUpdaterConfiguration()
+{
+    QSettings settings(configFile(), QSettings::IniFormat);
+    settings.beginGroup("Updater");
+    settings.remove("autoUpdateAttempted");
+    settings.remove("updateTargetVersion");
+    settings.remove("updateTargetVersionString");
+    settings.remove("updateAvailable");
+    settings.sync();
+}
+
 QString ConfigFile::backup(const QString &fileName) const
 {
     const QString baseFilePath = configPath() + fileName;
index 844036336a6f9b0c650276a0a7c67bacdd91fbe8..f38fba1f11ab047d1d9166a2b8081ed1feab0088 100644 (file)
@@ -48,6 +48,8 @@ public:
     [[nodiscard]] QString excludeFile(Scope scope) const;
     static QString excludeFileFromSystem(); // doesn't access config dir
 
+    void cleanUpdaterConfiguration();
+
     /**
      * Creates a backup of any given fileName in the config folder
      *